package cn.cosmosx.base.pdf;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegExUtil {
    public static String find(String regex, String line) {
        Matcher matcher = Pattern.compile(regex).matcher(line);
        if (matcher.find()) {
            return matcher.group();
        }
        return null;
    }

    public static String[] findMulti(String regex, String line) {
        Matcher matcher = Pattern.compile(regex).matcher(line);
        List<String> result = new ArrayList<>();
        while (matcher.find()) {
            String name = matcher.group();
            result.add(name);
        }
        return result.toArray(new String[0]);
    }
}
